import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import {JVxeTypes,JVxeColumn} from '/@/components/jeecg/JVxeTable/types'
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '隐患名称',
    align:"center",
    dataIndex: 'dangerName'
   },
   {
    title: '隐患描述',
    align:"center",
    dataIndex: 'dangerDesc'
   },
   {
    title: '隐患等级',
    align:"center",
    dataIndex: 'dangerLevel_dictText'
   },
   {
    title: '隐患来源',
    align:"center",
    dataIndex: 'dangerSrc_dictText'
   },
   {
    title: '隐患治理类型',
    align:"center",
    dataIndex: 'dangerManageType_dictText'
   },
   {
    title: '所属装置',
    align:"center",
    dataIndex: 'riskDeviceId_dictText'
   },
   {
    title: '所属单元',
    align:"center",
    dataIndex: 'riskUnitId_dictText'
   },
   {
    title: '隐患产生原因',
    align:"center",
    dataIndex: 'dangerReason'
   },
   {
    title: '资金',
    align:"center",
    dataIndex: 'cost'
   },
   {
    title: '隐患治理期限',
    align:"center",
    dataIndex: 'dangerManageDeadline'
   },
   {
    title: '隐患状态',
    align:"center",
    dataIndex: 'dangerState_dictText'
   },
   {
    title: '隐患类型',
    align:"center",
    dataIndex: 'hazardDangerType_dictText'
   },
   {
    title: '登记人姓名',
    align:"center",
    dataIndex: 'registrant_dictText'
   },
   {
    title: '控制措施',
    align:"center",
    dataIndex: 'controlMeasures'
   },
  //  {
  //   title: '管控措施',
  //   align:"center",
  //   dataIndex: 'riskMeasureId_dictText'
  //  },
   {
    title: '登记时间',
    align:"center",
    dataIndex: 'registTime'
   },
   {
    title: '整改责任人姓名',
    align:"center",
    dataIndex: 'liablePerson_dictText'
   },
   {
    title: '验收人',
    align:"center",
    dataIndex: 'checkAcceptPerson_dictText'
   },
  //  {
  //   title: '验收情况',
  //   align:"center",
  //   dataIndex: 'checkAcceptComment'
  //  },
   {
    title: '验收时间',
    align:"center",
    dataIndex: 'checkAcceptTime'
   },
   {
    title: '图片',
    align:"center",
    dataIndex: 'img',
    customRender:render.renderImage,
   },
  //  {
  //   title: '删除状态',
  //   align:"center",
  //   dataIndex: 'deleted_dictText'
  //  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "隐患等级",
      field: "dangerLevel",
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"dangerLevel"
      },
      //colProps: {span: 6},
 	},
	{
      label: "隐患来源",
      field: "dangerSrc",
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"dangerSrc"
      },
      //colProps: {span: 6},
 	},
	{
      label: "隐患治理类型",
      field: "dangerManageType",
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"dangerManageType"
      },
      //colProps: {span: 6},
 	},
	{
      label: "所属装置",
      field: "riskDeviceId",
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"tb_base_risk_device,name,id"
      },
      //colProps: {span: 6},
 	},
	{
      label: "所属单元",
      field: "riskUnitId",
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"tb_base_risk_unit,risk_unit_name,id"
      },
      //colProps: {span: 6},
 	},
	{
      label: "隐患名称",
      field: "dangerName",
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "隐患描述",
      field: "dangerDesc",
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "隐患状态",
      field: "dangerState",
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"dangerState"
      },
      //colProps: {span: 6},
 	},
	{
      label: "隐患类型",
      field: "hazardDangerType",
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"hazardDangerType"
      },
      //colProps: {span: 6},
 	},
	{
      label: "登记人姓名",
      field: "registrant",
      component: 'JSelectUser',
      //colProps: {span: 6},
 	},
     {
      label: "登记时间",
      field: "registTime",
      component: 'RangePicker',
      componentProps: {
          showTime:true
      },
      //colProps: {span: 6},
	},
	{
      label: "整改责任人姓名",
      field: "liablePerson",
      component: 'JSelectUser',
      //colProps: {span: 6},
 	},
	{
      label: "验收人",
      field: "checkAcceptPerson",
      component: 'JSelectUser',
      //colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '隐患等级',
    field: 'dangerLevel',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"dangerLevel"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入隐患等级!'},
          ];
     },
  },
  {
    label: '隐患来源',
    field: 'dangerSrc',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"dangerSrc"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入隐患来源!'},
          ];
     },
  },
  {
    label: '隐患治理类型',
    field: 'dangerManageType',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"dangerManageType"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入隐患治理类型!'},
          ];
     },
  },
  {
    label: '所属装置',
    field: 'riskDeviceId',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"tb_base_risk_device,name,id"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入所属装置!'},
          ];
     },
  },
  {
    label: '所属单元',
    field: 'riskUnitId',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"tb_base_risk_unit,risk_unit_name,id"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入所属单元!'},
          ];
     },
  },
  {
    label: '隐患名称',
    field: 'dangerName',
    component: 'InputTextArea',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入隐患名称!'},
          ];
     },
  },
  {
    label: '隐患描述',
    field: 'dangerDesc',
    component: 'InputTextArea',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入隐患描述!'},
          ];
     },
  },
  {
    label: '隐患产生原因',
    field: 'dangerReason',
    component: 'InputTextArea',
  },
  {
    label: '资金',
    field: 'cost',
    component: 'InputNumber',
  },
  {
    label: '隐患治理期限',
    field: 'dangerManageDeadline',
    component: 'DatePicker',
    componentProps: {
       showTime:true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
     },
  },
  {
    label: '隐患状态',
    field: 'dangerState',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"dangerState"
     },
  },
  {
    label: '隐患类型',
    field: 'hazardDangerType',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"hazardDangerType"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入隐患类型!'},
          ];
     },
  },
  {
    label: '登记人姓名',
    field: 'registrant',
    component: 'JSelectUser',
    componentProps:{
        labelKey:'realname',
     },
  },
  {
    label: '控制措施',
    field: 'controlMeasures',
    component: 'Input',
  },
  {
    label: '管控措施',
    field: 'riskMeasureId',
    component: 'JSearchSelect',
    componentProps:{
       dict:"tb_base_control_measures,risk_measure_desc,id"
    },
  },
  {
    label: '登记时间',
    field: 'registTime',
    component: 'DatePicker',
    componentProps: {
       showTime:true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
     },
  },
  {
    label: '整改责任人姓名',
    field: 'liablePerson',
    component: 'JSelectUser',
    componentProps:{
        labelKey:'realname',
     },
  },
  {
    label: '验收人',
    field: 'checkAcceptPerson',
    component: 'JSelectUser',
    componentProps:{
        labelKey:'realname',
     },
  },
  {
    label: '验收情况',
    field: 'checkAcceptComment',
    component: 'InputTextArea',
  },
  {
    label: '验收时间',
    field: 'checkAcceptTime',
    component: 'DatePicker',
    componentProps: {
       showTime:true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
     },
  },
  {
    label: '图片',
    field: 'img',
     component: 'JImageUpload',
     componentProps:{
      },
  },
  {
    label: '删除状态',
    field: 'deleted',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"yn"
     },
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];
//子表单数据
//子表表格配置
export const tbBaseDangerInvestigationReocrdColumns: JVxeColumn[] = [
    {
      title: '治理时间',
      key: 'governorTime',
      type: JVxeTypes.datetime,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
        validateRules: [
          { required: true, message: '${title}不能为空' },
        ],
    },
    {
      title: '治理人',
      key: 'governor',
      type: JVxeTypes.userSelect,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
        validateRules: [
          { required: true, message: '${title}不能为空' },
        ],
    },
    {
      title: '治理状态',
      key: 'status',
      type: JVxeTypes.select,
      options:[],
      dictCode:"dangerState",
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
        validateRules: [
          { required: true, message: '${title}不能为空' },
        ],
    },
    {
      title: '图片',
      key: 'img',
      type: JVxeTypes.image,
      token:true,
      responseName:"message",
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
        validateRules: [
          { required: true, message: '${title}不能为空' },
        ],
    },
  ]

// 高级查询数据
export const superQuerySchema = {
  dangerLevel: {title: '隐患等级',order: 0,view: 'list', type: 'string',dictCode: 'dangerLevel',},
  dangerSrc: {title: '隐患来源',order: 1,view: 'list', type: 'string',dictCode: 'dangerSrc',},
  dangerManageType: {title: '隐患治理类型',order: 2,view: 'list', type: 'string',dictCode: 'dangerManageType',},
  riskDeviceId: {title: '所属装置',order: 3,view: 'radio', type: 'string',},
  riskUnitId: {title: '所属单元',order: 4,view: 'list', type: 'string',dictTable: "tb_base_risk_unit", dictCode: 'id', dictText: 'risk_unit_name',},
  dangerName: {title: '隐患名称',order: 5,view: 'textarea', type: 'string',},
  dangerDesc: {title: '隐患描述',order: 6,view: 'textarea', type: 'string',},
  dangerReason: {title: '隐患产生原因',order: 7,view: 'textarea', type: 'string',},
  cost: {title: '资金',order: 8,view: 'number', type: 'number',},
  dangerManageDeadline: {title: '隐患治理期限',order: 9,view: 'datetime', type: 'string',},
  dangerState: {title: '隐患状态',order: 10,view: 'list', type: 'string',dictCode: 'dangerState',},
  hazardDangerType: {title: '隐患类型',order: 11,view: 'list', type: 'string',dictCode: 'hazardDangerType',},
  registrant: {title: '登记人姓名',order: 12,view: 'sel_user', type: 'string',},
  controlMeasures: {title: '控制措施',order: 13,view: 'text', type: 'string',},
  riskMeasureId: {title: '管控措施',order: 14,view: 'sel_search', type: 'string',dictTable: "tb_base_control_measures", dictCode: 'id', dictText: 'risk_measure_desc',},
  registTime: {title: '登记时间',order: 15,view: 'datetime', type: 'string',},
  liablePerson: {title: '整改责任人姓名',order: 16,view: 'sel_user', type: 'string',},
  checkAcceptPerson: {title: '验收人',order: 17,view: 'sel_user', type: 'string',},
  checkAcceptComment: {title: '验收情况',order: 18,view: 'textarea', type: 'string',},
  checkAcceptTime: {title: '验收时间',order: 19,view: 'datetime', type: 'string',},
  img: {title: '图片',order: 20,view: 'image', type: 'string',},
  deleted: {title: '删除状态',order: 21,view: 'radio', type: 'string',},
  //子表高级查询
  tbBaseDangerInvestigationReocrd: {
    title: '隐患治理过程信息',
    view: 'table',
    fields: {
        governorTime: {title: '治理时间',order: 0,view: 'datetime', type: 'string',},
        governor: {title: '治理人',order: 1,view: 'sel_user', type: 'string',},
        status: {title: '治理状态',order: 2,view: 'list', type: 'string',dictCode: 'dangerState',},
        img: {title: '图片',order: 3,view: 'image', type: 'string',},
    }
  },
};
